package com.lzj.controller;

import com.lzj.entity.Employee;
import com.lzj.service.EmployeeService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @autor:lzj
 * @date:2022/2/27
 */
@Controller
@RequestMapping("/admin")
public class ApproveaccountController {
    public static final String PENDING_PPROVE="0";//用户状态待审批
    @Autowired
    EmployeeService employeeService;

    @RequestMapping("/approveaccount")
    public String approveaccount(Model model){
        List<Employee> allEmps = employeeService.getAllEmpsByStatus(PENDING_PPROVE);
        model.addAttribute("emps",allEmps);
        return "approveaccount";
    }

    @RequestMapping("/updatestatus/{employeeid}/{status}")
    public String updatestatus(@PathVariable int employeeid, @PathVariable String status){
        System.out.println(employeeid);
        System.out.println(status);
        int approveaccount = employeeService.approveaccount(employeeid, status);
        return "redirect:/admin/approveaccount";
    }
}
